/*
 * File:    CookieStore.java
 * Created: 17-Feb-2009
 * Version: $Id$
 *
 * COPYRIGHT (C) 2009, Bitgate Mobile, LLC.  All Rights Reserved.
 *
 * software@bitgatemobile.com
 */

package com.bitgate.util.service.protocol.http.store;

import java.util.Date;

/**
 * This is a storage class used to store information about a cookie that was sent, or to be sent, to a client.
 * 
 * @author kenji
 * @since Webplasm 2
 */
public class CookieStore {
	private String name;
	private Date expiration;
	private String path;
	private String domain;
	private String value;
	
	/**
	 * Default constructor.
	 */
	public CookieStore() {
		this(null, null);
	}
	
	/**
	 * Constructor containing the name and value for a cookie object.
	 * 
	 * @param name The name of the cookie.
	 * @param value The value assigned with that cookie.
	 */
	public CookieStore(String name, String value) {
		this.name = name;
		this.value = value;
		this.expiration = null;
		this.path = null;
		this.domain = null;
	}
	
	/**
	 * Sets the name of the cookie.
	 * 
	 * @param name The name to set.
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * Sets the value for the cookie.
	 * 
	 * @param value The value to set.
	 */
	public void setValue(String value) {
		this.value = value;
	}
	
	/**
	 * Sets the expiration time for the cookie.
	 * 
	 * @param expiration <code>Date</code> containing the expiration date and time.
	 */
	public void setExpiration(Date expiration) {
		this.expiration = expiration;
	}
	
	/**
	 * Sets the path for the cookie.
	 * 
	 * @param path The path to assign.
	 */
	public void setPath(String path) {
		this.path = path;
	}
	
	/**
	 * Sets the domain assigned to the cookie.
	 * 
	 * @param domain The domain to assign.
	 */
	public void setDomain(String domain) {
		this.domain = domain;
	}
	
	/**
	 * Retrieves the name assigned to the cookie.
	 * 
	 * @return <code>String</code> containing the cookie name.
	 */
	public String getName() {
		return this.name;
	}
	
	/**
	 * Retrieves the expiration date.
	 * 
	 * @return <code>Date</code> containing the expiration date and time.
	 */
	public Date getExpiration() {
		return this.expiration;
	}
	
	/**
	 * Retrieves the path assigned to the cookie.
	 * 
	 * @return <code>String</code> containing the path.
	 */
	public String getPath() {
		return this.path;
	}
	
	/**
	 * Retrieves the domain for this cookie.
	 * 
	 * @return <code>String</code> containing the cookie name.
	 */
	public String getDomain() {
		return this.domain;
	}
	
	/**
	 * Retrieves the cookie value.
	 * 
	 * @return <code>String</code> containing the value.
	 */
	public String getValue() {
		return this.value;
	}
	
	@Override
	public String toString() {
		return "[CookieStore: Name=" + name +
			   " Value=" + value + 
			   " Expiration=" + expiration +
			   " Path=" + path +
			   " Domain=" + domain + "]";
	}
}